2 ROS2 Nodes
- Install the turtlesim package for your ROS 2 distro
sudo apt update && sudo apt install ros-$ROS_DISTRO-turtlesim -y
- Check turtlesim installation:
ros2 pkg executables turtlesim
- To start turtlesim, enter the following command in your terminal:
ros2 run turtlesim turtlesim_node
- Open a new terminal (Ctr + Alt + T).
- Now you will run a new node to control the turtle in the first node:
ros2 run turtlesim turtle_teleop_key
- You can see the nodes, and their associated topics, services, and actions, using the list subcommands of the respective commands:
- try these:
sudo apt update && sudo apt install ros-$ROS_DISTRO-rqt* -y
- Open a new terminal (Ctr + Alt + T).
-
/SPAWN

-
/SET_PEN

Remapping
- To run two turtlebots with teloop key. In a new terminal, source ROS 2, and run:
ros2 run turtlesim turtle_teleop_key --ros-args --remap turtle1/cmd_vel:=turtle2/cmd_vel
Understanding nodes
ROS2 RUN
- The command ros2 run launches an executable from a package.
- ros2 run <package_name> <executable_name>
- To run turtlesim, open a new terminal, and enter the following command:
ros2 run turtlesim turtlesim_node
ros2 node list
- Open a new terminal while turtlesim is still running in the other one, and enter the following command:
ros2 run turtlesim turtle_teleop_key
- Now, let’s reassign the name of our /turtlesim node. In a new terminal, run the following command:
ros2 run turtlesim turtlesim_node --ros-args --remap __node:=my_turtle
ros2 node info
- Now that you know the names of your nodes, you can access more information about them with: ros2 node info <node_name>
ros2 node info /my_turtle